package com.meritdata.cloud.data.service.approval.controller;

import com.meritdata.cloud.data.service.approval.service.IDownloadProposeRecordService;
import com.meritdata.cloud.resultmodel.ResultBody;
import com.meritdata.cloud.resultmodel.ResultStatus;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/approval")
@Api(value = "数据审批信息提交-DataDirectoryController", tags = "数据审批信息提交")
public class ApprovalController {

    @Autowired
    private IDownloadProposeRecordService downloadProposeRecordService;

    /**
     * 提交审批意见方法
     *
     * proposerId:申请id
     * operator:操作人id
     * operateType:操作类型
     * text：操作意见
     */
    @RequestMapping("/submit")
    @ApiOperation(value = "提交数据审批信息接口", notes = "添加数据审批操作日志")
    public ResultBody submitApprovalInfo(@ApiParam(value = "申请id") @RequestParam Long proposerId,
                                         @ApiParam(value = "操作人id") @RequestParam String operator,
                                         @ApiParam(value = "操作类型") @RequestParam int operateType,
                                         @ApiParam(value = "操作意见") @RequestParam String text) {
        try {
            return ResultBody.success(downloadProposeRecordService.dealApprovalInfo(proposerId,operator,operateType,text));
        } catch (RuntimeException e) {
            return ResultBody.failure(ResultStatus.DATA_OPERATION_ERROR, e);
        }
    }


}
